/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * DialogBox.java
 *
 * Created on 23 févr. 2010, 10:40:22
 */
package chat.client;

import org.jdesktop.application.Action;

/**
 * The application dialog (Box generic)
 * @author berthise
 */
public class DialogBox extends javax.swing.JDialog {

    private ChatView client = null;

    /**
     * Creates new form DialogBox
     * @param client
     * @param parent
     * @param action
     * @param text 
     * @param modal
     * @param title
     */
    public DialogBox(ChatView client, java.awt.Frame parent, boolean modal, String text, String title, String action) {
        super(parent, modal);
        initComponents();
        this.client = client;
        getRootPane().setDefaultButton(okButton);
        infoLabel.setText(text);
        this.setTitle(title);
        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(ChatApp.class).getContext().getActionMap(DialogBox.class, this);
        okButton.setAction(actionMap.get(action));
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        infoLabel = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        okButton = new javax.swing.JButton();
        cancelButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setMinimumSize(new java.awt.Dimension(150, 54));
        setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
        setName("dialogBox"); // NOI18N

        jPanel1.setBorder(javax.swing.BorderFactory.createEmptyBorder(8, 8, 8, 8));
        jPanel1.setName("jPanel1"); // NOI18N
        jPanel1.setLayout(new java.awt.GridLayout(2, 0, 0, 10));

        jPanel3.setName("jPanel3"); // NOI18N
        jPanel3.setLayout(new java.awt.GridLayout(1, 0));

        infoLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        infoLabel.setName("infoLabel"); // NOI18N
        jPanel3.add(infoLabel);

        jPanel1.add(jPanel3);

        jPanel2.setName("jPanel2"); // NOI18N
        jPanel2.setLayout(new java.awt.GridLayout(1, 2, 16, 0));

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance().getContext().getActionMap(DialogBox.class, this);
        okButton.setAction(actionMap.get("quitApplication")); // NOI18N
        okButton.setName("Exit"); // NOI18N
        jPanel2.add(okButton);

        cancelButton.setAction(actionMap.get("closeQuitBox")); // NOI18N
        cancelButton.setName("cancelButton"); // NOI18N
        jPanel2.add(cancelButton);

        jPanel1.add(jPanel2);

        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     *
     */
    @Action
    public void closeQuitBox() {
        dispose();
    }

    /**
     *
     */
    @Action
    public void quitReceive() {
        client.setAckDialog(true);
        dispose();
    }

    /*
     * error dialog
     */
    /**
     *
     */
    @Action
    public void quitError() {
        dispose();
    }

    /*
     * quit diqlog
     */
    /**
     *
     */
    @Action
    public void quitApplication() {
        client.closeApplication();
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton cancelButton;
    private javax.swing.JLabel infoLabel;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JButton okButton;
    // End of variables declaration//GEN-END:variables
}
